package ustc.xiaoyang.karl.hashtable;

import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * 349.两个数组元素的交集
 */
public class IntersectionOfTwoArrays349 {
    public static void main(String[] args) {
    }
    public int[] intersection(int[] nums1, int[] nums2) {
        Set<Integer> set = Arrays.stream(nums1).boxed().collect(Collectors.toSet());
        return Arrays.stream(nums2).filter((num)->set.remove(num)).toArray();
    }
}
